
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
const state={   //要设置的全局访问的state对象

  massageNum:1,
  massageName:{
    '1':'管理员',
     '2':'财务',
    '3':'员工'
  },
  massageJurisdiction:{
    '1':[1,2,3,4,5,6,7],
    '2':[3,4,5,6,7],
    '3':[3,4,6,7]
  },
  organizationList:{
    '100001':{organizationName:"样品机构01"},
    '100002':{organizationName:"样品机构02"},
    '100003':{organizationName:"样品机构03"},

  },
  userPresentOrganization:'100001',
  massageArr: [
    {actionName: '设置时间', iconimg:require('../assets/icon/SetTime.png'),path:'/SetTime',num:1},
    {actionName: '设置价格', iconimg:require( '../assets/icon/SetPrice.png'),path:'/SetPrice',num:2},
    {actionName: '我的机构', iconimg: require('../assets/icon/SetOrganization.png'),path:'/SetOrganization',num:3},
    {actionName: '订单统计', iconimg: require('../assets/icon/OrdersStatistics.png'),path:'/OrdersStatistics',num:4},
    {actionName: '员工管理', iconimg: require('../assets/icon/StaffMassage.png'),path:'/StaffMassage',num:5},
    {actionName: '角色管理', iconimg: require('../assets/icon/RoleMassage.png'),path:'/RoleMassage',num:6},
    {actionName: '设备监控', iconimg: require('../assets/icon/EquipmentMonitoring.png'),path:'/EquipmentMonitoring',num:7},



  ],

  //要设置的初始属性值
};
const getters = {   //实时监听state值的变化(最新状态)
  getUserPresentOrganization(state){
    return state.userPresentOrganization
  },

  getOrganizationList(state){
    return state.organizationList
  },
  getMassageArr:(state)=>{
    return  state.massageArr.filter( (r)=> {
console.log(r.num)
 // console.log(state.massageJurisdiction[state.massageNum].indexOf(2))
 //      console.log(state.massageJurisdiction[state.massageNum])
 //      console.log(state.massageJurisdiction[state.massageNum].indexOf((r.num))!==-1)
     return state.massageJurisdiction[state.massageNum].indexOf(r.num)!==-1
    })
  }
  ,
 getmMassageName(state){
   return state.massageName
 },
  getMssageJurisdiction(state){
   return state.massageJurisdiction
  },
  getMassageNum(state){
    return state.massageNum
  },
};
const mutations = {
  setMassageNum(state,num){
    state.massageNum=num
  },
  setUserPresentOrganization(state,organizationNum){
    state.userPresentOrganization=organizationNum
  }
};
const actions = {
  
};
const store = new Vuex.Store({
  state,
  getters,
  mutations,
  actions
});
export default store;
